package sctu.edu.java.year2016.team04.yanghuilin.day20160522.chapter5_2;

/**
 * Created by dell on 2016/5/22.
 * 创建一维数组arr[],将数组中最大的数输出。
 */
public class FiveTwo {
    public static void main(String[] args) {
        int arr[] = new int[]{30, 80, 31, 1, 64, 8, 14, 76};
        System.out.println("输出一维数组：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        int theMax = arr[0];
        for (int j = 0; j < arr.length - 1; j++) {
            if (theMax < arr[j + 1]) {
                theMax = arr[j + 1];
            }
        }
        System.out.println("\n一维数组中的最大值为： " + theMax);

    }
}